//tokens.h
//Header file for the tokenizer team
//Authors: Matthew Lorenzo and Daniel Diaz

//History:
// 2/15/12 - Created Header file and function/structure declarations in C. Will change to classes/vectors as soon as I get more familiar with C++ (Matthew Lorenzo)
// 2/22/12 - Attempted to convert header files (struct to class) in a format more suitable with C++ code. Still need to learn about vectors some more (Matthew Lorenzo)
// 2/27/12 - With the help of Sam, Daniel and I (matt) refined our header file to define the classes and functions of those clases. Also included a char in the Tokens class to help Identify the token type.
//Still needs to be tested

#ifndef TOKENS_H
#define TOKENS_H

#include <iostream>
#include <vector>
#include <string>

using namespace std;

//Declaring Tokens and TokensHeader class
class Tokens;
class TokensHeader;

//Defining Tokens class
class Tokens
        {
        vector<string> token;
                unsigned int linenumber;  
        unsigned int position;
                string filename;   //linenumber and filename associated with token
                public:
               
            Tokens(vector<string> x,unsigned int y,string z,unsigned int a)
            {
            position = a;
            token = x;
            filename = z;
            linenumber = y;
            }
            vector<string> ret_token()
            {
                return token;
            }
            string ret_filename()
            {
                return filename;
            }
            unsigned int ret_linenumber()
            {
                return linenumber;
            }
            unsigned int ret_pos()
            {
                return position;
            }
                };

class TokensHeader
        {
                vector<Tokens> *tokenlist;
               
        public:
       
        TokensHeader() //constructor
        {

            tokenlist= new vector<Tokens>;

        }  
       
                ~TokensHeader()
        {
            delete tokenlist;

        }
                void AppendToken(vector<string> x,unsigned int y, string z, unsigned int a)
        {
            tokenlist->push_back(Tokens(x,y,z,a));
        }

        void Set_TokenList(vector<Tokens> *x)
        {
            tokenlist=x;
        }
        vector<Tokens>* GetTokens()
        {
            return tokenlist;
        }
        vector<string> GetTokens(unsigned int i)
        {
            return (*tokenlist)[i].ret_token();
        }
        string GetTokens(unsigned int i,unsigned int j)
        {
            return ((*tokenlist)[i].ret_token())[j];
        }
        unsigned int GetLine(unsigned int i)
        {
            return (*tokenlist)[i].ret_linenumber();
        }
        string GetFile(unsigned int i)
        {
            return (*tokenlist)[i].ret_filename();
        }
        unsigned int GetSize()
        {
            return (unsigned int)((*tokenlist).size());
        }
        unsigned int GetPos(unsigned int i)
        {
            return (*tokenlist)[i].ret_pos();
        }
       
        };

//Tokenizing function declaration
void Tokenize(TokensHeader * TH, string filename);



#endif

